package com.yzd.learnjava.generics;

public class Holder<T> {
	private T value;
	public Holder() {}
	public Holder(T t) {
		this.value = t;
	}
	
	public void set(T t) {
		this.value = t;
	}
	
	public T get() {
		return value;
	}
	
	public boolean equals(Object obj) {
		return value.equals(obj);
	}
	public static void main(String[] args) {
		Holder<Apple2> apHolder = new Holder<Apple2>(new Apple2());
		
		Apple2 apple2 = apHolder.get();
		
		apHolder.set(apple2);
		
		//Holder<Fruit2> fHolder = apHolder;
		Holder<? extends Fruit2> fHolder = apHolder;
		Fruit2 f = fHolder.get();
		//fHolder.set(f);
		Apple2 a = (Apple2)fHolder.get();
		
		try {
			Orange2 o2 = (Orange2)fHolder.get();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
